//<template>
  <div>
      <tr>
          <td>标题</td>
          <td>查看</td>
      </tr>
      <tr v-for="i in new_list">
          <td>{{i.title}}</td>
          <td><button @click="todetail(i.id)">查看</button></td>
      </tr>
      <button @click="up()">上一页</button>
      <button v-for="i in page_list" :value="i" @click="get_num($event)">{{i}}</button>
      <button @click="down()">下一页</button>
  </div>
</template>

<script>
import axios from 'axios'
export default {
    data(){
        return{
            new_list:[],
            page_list:[],
            p:'1',
            num:0
        }
    },methods:{
        show(){
            axios({
                url:'http://127.0.0.1:8000/app03/newshow/',
                method:'get',
                params:{'qwe':this.p}
            }).then(res=>{
                console.log(res.data)
                this.new_list = res.data.new_list
                this.page_list = res.data.page_list
                this.num = res.data.page_num
            })
        },
        get_num(event){
            this.p = event.target.value
            this.show()
        },
        up(){
            if(this.p>1){
                this.p --
                this.show()
            }
        },
        down(){
            if(this.p<this.num){
                this.p ++
                this.show()
            }
        },
        todetail(id){
            this.$router.push({path:'/detailb/'+id})
        }
    },
    created(){
        this.show()
    }
}
</script>

<style>

</style>